package com.isesol.controller;

import com.isesol.model.*;
import com.isesol.service.*;
import com.isesol.service.impl.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.*;
import java.util.*;

@Controller
@RequestMapping
public class UserController{

	@Resource
	private UserServiceImpl userService;

	@RequestMapping("/showInfo/{userId}")
	public String showUserInfo(ModelMap modelMap, @PathVariable int userId){

		UserInfo userInfo = userService.getUserById(userId);
		modelMap.addAttribute("userInfo", userInfo);
		return "/user/showInfo";
	}

	@RequestMapping("/showInfos")
	@ResponseBody
	public Object showUserInfos(){

		List<UserInfo> userInfos = userService.getUsers();
		return userInfos;
	}
}
